package com.hospital.controller;

import com.hospital.exception.BusinessException;
import com.hospital.exception.SystemException;
import org.springframework.web.bind.annotation.ExceptionHandler;


/*
* 异常处理器
* */
//@RestControllerAdvice
public class ProjectExceptionAdvice {

    @ExceptionHandler(SystemException.class)
    public Result doSystemException(SystemException ex){
        return new Result(ex.getCode(),null,ex.getMessage());
    }

    @ExceptionHandler(BusinessException.class)
    public Result doBusinessException(BusinessException ex) {
        return new Result(ex.getCode(),null,ex.getMessage());
    }

    @ExceptionHandler(Exception.class)
    public void doException(Exception ex){
        System.out.println("有异常");
    }
}
